﻿using System.Collections.Generic;
using ZeldoEngineObjects.Project;
using ZeldoEngineServices.Project;
using ZeldoEngine.Ressources;
using ZeldoEngineObjects.Maps;
using ZeldoEngine.Game.Variables;

namespace ZeldoEngine
{
    public class ProjectManager
    {
        private ProjectModel _project;
        public RessourcesManager Ressources { get; set; }

        public RegistresModel Registres
        {
            get
            {
                if (this._project != null)
                {
                    return this._project.Registres;
                }
                return null;
            }

        }

        public ProjectManager()
        {
            this.Ressources = new RessourcesManager();
        }

        public void CreerProjet(string nom, string chemin)
        {
            // On créer le projet avec le nom et le chemin des dossiers
            this._project = ProjectService.CreerProjet(nom, chemin);

            // On charge les ressources du projet
            this.Ressources.ChargerRessources(chemin);
        }

        public void AjouterCarte(MapModel mapSubmited)
        {
            this._project.Registres.Cartes.Add(mapSubmited);
        }

        public IEnumerable<string> LireListeChipsets()
        {
            var liste = new List<string>();

            foreach (var chipset in this.Ressources.Chipsets.Chipsets)
            {
                liste.Add(chipset.Nom);
            }

            return liste;
        }
    }
}
